# -*- coding: utf-8 -*-
"""
date: Fri Dec 28 15:20:45 2018
python: Anaconda 3.6.5
author: kanade
email: kanade@blisst.cn
"""
import numpy as np


def foo(a, b):
    c = a + b
    d = a - b
    e = a * b
    return c, d, e


# 基于通用函数的闭包
# ————从函数中返回封装了函数的通用函数
def hum(a):
    def fun(b):
        c = a + b
        d = a - b
        e = a * b
        return c, d, e
    return np.frompyfunc(fun, 1, 3)


print(type(foo))
A = np.array([1, 2, 3, 4, 5])
B = np.array([5, 4, 3, 2, 1])
bar = np.frompyfunc(foo, 2, 3)
print(type(bar))
C, D, E = bar(A, B)
print(C, D, E, sep='\n')
F, G, H = hum(100)(A)
print(F, G, H, sep='\n')
